 Imports MySql.Data.MySqlClient 
 Imports System.Data.OleDb
Imports System.Data.SqlClient
 Imports System .Data .SqlServerCe 
 Imports System.Data.OracleClient 
Imports System.Data
Imports DTO
Public Class QUYENCHITIETDao
Inherits AbstractDao
 #Region "New" 
 Public Sub New(ByVal connection As KetNoiDto)
 MyBase.New(connection)
 End Sub
 Public Sub New( ByVal iD As System.Int32, ByVal connection As KetNoiDto)
 MyBase.New("QUYENCHITIET", "select * from QUYENCHITIET where iD=" & iD & "", connection)
 End Sub
 #End Region 
 Public Sub Them(ByVal Dto As QUYENCHITIETDto)
 Dim strsql As String
 strsql = "Insert into QUYENCHITIET(Quyen,TenForm,TenButon,Trangthai,Ghichu) values (?,?,?,?,?)
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 Dim cmd As New OleDbCommand(strsql, Ket_noi_access)
cmd.Parameters.Add("@Quyen", OleDbType.Integer)
cmd.Parameters.Add("@TenForm", OleDbType.VarWChar)
cmd.Parameters.Add("@TenButon", OleDbType.VarWChar)
cmd.Parameters.Add("@Trangthai", OleDbType.Integer)
cmd.Parameters.Add("@Ghichu", OleDbType.VarWChar)
cmd.Parameters("@Quyen").Value = Dto.Quyen
cmd.Parameters("@TenForm").Value = Dto.TenForm
cmd.Parameters("@TenButon").Value = Dto.TenButon
cmd.Parameters("@Trangthai").Value = Dto.Trangthai
cmd.Parameters("@Ghichu").Value = Dto.Ghichu
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New OleDbCommand(strsql, Ket_noi_access)
 Dto.iD = cmd.ExecuteScalar()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress
 strsql = "Insert into QUYENCHITIET(Quyen,TenForm,TenButon,Trangthai,Ghichu) values (@Quyen,@TenForm,@TenButon,@Trangthai,@Ghichu)
 Dim cmd As New sqlCommand(strsql, Ket_noi_sql)
cmd.Parameters.Add("@Quyen", SqlDbType.Int)
cmd.Parameters.Add("@TenForm", SqlDbType.NVarChar)
cmd.Parameters.Add("@TenButon", SqlDbType.NVarChar)
cmd.Parameters.Add("@Trangthai", SqlDbType.Int)
cmd.Parameters.Add("@Ghichu", SqlDbType.NVarChar)
cmd.Parameters("@Quyen").Value = Dto.Quyen
cmd.Parameters("@TenForm").Value = Dto.TenForm
cmd.Parameters("@TenButon").Value = Dto.TenButon
cmd.Parameters("@Trangthai").Value = Dto.Trangthai
cmd.Parameters("@Ghichu").Value = Dto.Ghichu
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New sqlCommand(strsql, Ket_noi_sql)
 Dto.iD = cmd.ExecuteScalar()
 Case Class_KieuDL.SqlCe
 strsql = "Insert into QUYENCHITIET(Quyen,TenForm,TenButon,Trangthai,Ghichu) values (@Quyen,@TenForm,@TenButon,@Trangthai,@Ghichu)
 Dim cmd As New sqlceCommand(strsql, Ket_noi_SqlCe)
cmd.Parameters("@Quyen").Value = Dto.Quyen
cmd.Parameters("@TenForm").Value = Dto.TenForm
cmd.Parameters("@TenButon").Value = Dto.TenButon
cmd.Parameters("@Trangthai").Value = Dto.Trangthai
cmd.Parameters("@Ghichu").Value = Dto.Ghichu
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strsql = "Insert into QUYENCHITIET(Quyen,TenForm,TenButon,Trangthai,Ghichu) values (@Quyen,@TenForm,@TenButon,@Trangthai,@Ghichu)
 Dim cmd As New OracleCommand(strsql, Ket_noi_Oracle)
cmd.Parameters("@Quyen").Value = Dto.Quyen
cmd.Parameters("@TenForm").Value = Dto.TenForm
cmd.Parameters("@TenButon").Value = Dto.TenButon
cmd.Parameters("@Trangthai").Value = Dto.Trangthai
cmd.Parameters("@Ghichu").Value = Dto.Ghichu
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Mysql
 strsql = "Insert into QUYENCHITIET(Quyen,TenForm,TenButon,Trangthai,Ghichu) values (@Quyen,@TenForm,@TenButon,@Trangthai,@Ghichu)
 Dim cmd As New MySqlCommand(strsql, Ket_noi_MySql)
cmd.Parameters.Add("@Quyen", MySqlDbType.Int32)
cmd.Parameters.Add("@TenForm", MySqlDbType.String)
cmd.Parameters.Add("@TenButon", MySqlDbType.String)
cmd.Parameters.Add("@Trangthai", MySqlDbType.Int32)
cmd.Parameters.Add("@Ghichu", MySqlDbType.String)
cmd.Parameters("@Quyen").Value = Dto.Quyen
cmd.Parameters("@TenForm").Value = Dto.TenForm
cmd.Parameters("@TenButon").Value = Dto.TenButon
cmd.Parameters("@Trangthai").Value = Dto.Trangthai
cmd.Parameters("@Ghichu").Value = Dto.Ghichu
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub Xoa( ByVal iD As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
strSQL = "Delete From QUYENCHITIET Where iD= ? 
Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@iD",OleDbType.Integer).Value = iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
strSQL = "Delete From QUYENCHITIET Where iD= @iD
Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@iD",SqlDbType.Int).value=iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
strSQL = "Delete From QUYENCHITIET Where iD=" & iD & "
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
strSQL = "Delete From QUYENCHITIET Where iD=" & iD & "
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
strSQL = "Delete From QUYENCHITIET Where iD=" & iD & "
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub sua(ByVal dto As QUYENCHITIETDto)
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update QUYENCHITIET Set Quyen=? ,TenForm=? ,TenButon=? ,Trangthai=? ,Ghichu= ? where iD= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@Quyen", OleDbType.Integer)
cmd.Parameters.Add("@TenForm", OleDbType.VarWChar)
cmd.Parameters.Add("@TenButon", OleDbType.VarWChar)
cmd.Parameters.Add("@Trangthai", OleDbType.Integer)
cmd.Parameters.Add("@Ghichu", OleDbType.VarWChar)
cmd.Parameters.Add("@iD", OleDbType.Integer)
cmd.Parameters("@Quyen").Value = dto.Quyen
cmd.Parameters("@TenForm").Value = dto.TenForm
cmd.Parameters("@TenButon").Value = dto.TenButon
cmd.Parameters("@Trangthai").Value = dto.Trangthai
cmd.Parameters("@Ghichu").Value = dto.Ghichu
cmd.Parameters("@iD").Value = dto.iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update QUYENCHITIET Set Quyen= @Quyen , TenForm= @TenForm , TenButon= @TenButon , Trangthai= @Trangthai , Ghichu= @Ghichu where iD= @iD"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@Quyen", SqlDbType.Int)
cmd.Parameters.Add("@TenForm", SqlDbType.NVarChar)
cmd.Parameters.Add("@TenButon", SqlDbType.NVarChar)
cmd.Parameters.Add("@Trangthai", SqlDbType.Int)
cmd.Parameters.Add("@Ghichu", SqlDbType.NVarChar)
cmd.Parameters.Add("@iD", SqlDbType.Int)
cmd.Parameters("@Quyen").Value = dto.Quyen
cmd.Parameters("@TenForm").Value = dto.TenForm
cmd.Parameters("@TenButon").Value = dto.TenButon
cmd.Parameters("@Trangthai").Value = dto.Trangthai
cmd.Parameters("@Ghichu").Value = dto.Ghichu
cmd.Parameters("@iD").Value = dto.iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update QUYENCHITIET Set Quyen= @Quyen , TenForm= @TenForm , TenButon= @TenButon , Trangthai= @Trangthai , Ghichu= @Ghichu where iD= @iD"
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
cmd.Parameters("@Quyen").Value = dto.Quyen
cmd.Parameters("@TenForm").Value = dto.TenForm
cmd.Parameters("@TenButon").Value = dto.TenButon
cmd.Parameters("@Trangthai").Value = dto.Trangthai
cmd.Parameters("@Ghichu").Value = dto.Ghichu
cmd.Parameters("@iD").Value = dto.iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update QUYENCHITIET Set Quyen= @Quyen , TenForm= @TenForm , TenButon= @TenButon , Trangthai= @Trangthai , Ghichu= @Ghichu where iD= @iD"
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
cmd.Parameters("@Quyen").Value = dto.Quyen
cmd.Parameters("@TenForm").Value = dto.TenForm
cmd.Parameters("@TenButon").Value = dto.TenButon
cmd.Parameters("@Trangthai").Value = dto.Trangthai
cmd.Parameters("@Ghichu").Value = dto.Ghichu
cmd.Parameters("@iD").Value = dto.iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update QUYENCHITIET Set Quyen= @Quyen , TenForm= @TenForm , TenButon= @TenButon , Trangthai= @Trangthai , Ghichu= @Ghichu where iD= @iD"
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
cmd.Parameters.Add("@Quyen", MySqlDbType.Int32)
cmd.Parameters.Add("@TenForm", MySqlDbType.String)
cmd.Parameters.Add("@TenButon", MySqlDbType.String)
cmd.Parameters.Add("@Trangthai", MySqlDbType.Int32)
cmd.Parameters.Add("@Ghichu", MySqlDbType.String)
cmd.Parameters.Add("@iD", MySqlDbType.Int32)
cmd.Parameters("@Quyen").Value = dto.Quyen
cmd.Parameters("@TenForm").Value = dto.TenForm
cmd.Parameters("@TenButon").Value = dto.TenButon
cmd.Parameters("@Trangthai").Value = dto.Trangthai
cmd.Parameters("@Ghichu").Value = dto.Ghichu
cmd.Parameters("@iD").Value = dto.iD
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub SuaQuyen( ByVal Quyen as System.Int32, ByVal iD As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update QUYENCHITIET Set Quyen = ?  where iD= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@Quyen", OleDbType.Integer)
 cmd.Parameters.Add("@iD", OleDbType.Integer)
 cmd.Parameters("@Quyen").Value =  Quyen
cmd.Parameters("@iD").Value =  iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update QUYENCHITIET Set Quyen = @Quyen  where iD= @iD"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@Quyen", SqlDbType.Int)
 cmd.Parameters.Add("@iD", SqlDbType.Int)
 cmd.Parameters("@Quyen").Value =  Quyen
cmd.Parameters("@iD").Value =  iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update QUYENCHITIET Set Quyen =" & Quyen & "  where iD=" & iD & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update QUYENCHITIET Set Quyen =" & Quyen & "  where iD=" & iD & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update QUYENCHITIET Set Quyen =" & Quyen & "  where iD=" & iD & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaTenForm( ByVal TenForm as System.String, ByVal iD As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update QUYENCHITIET Set TenForm = ?  where iD= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@TenForm", OleDbType.VarWChar)
 cmd.Parameters.Add("@iD", OleDbType.Integer)
 cmd.Parameters("@TenForm").Value =  TenForm
cmd.Parameters("@iD").Value =  iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update QUYENCHITIET Set TenForm = @TenForm  where iD= @iD"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@TenForm", SqlDbType.NVarChar)
 cmd.Parameters.Add("@iD", SqlDbType.Int)
 cmd.Parameters("@TenForm").Value =  TenForm
cmd.Parameters("@iD").Value =  iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update QUYENCHITIET Set TenForm =" & TenForm & "  where iD=" & iD & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update QUYENCHITIET Set TenForm =" & TenForm & "  where iD=" & iD & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update QUYENCHITIET Set TenForm =" & TenForm & "  where iD=" & iD & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaTenButon( ByVal TenButon as System.String, ByVal iD As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update QUYENCHITIET Set TenButon = ?  where iD= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@TenButon", OleDbType.VarWChar)
 cmd.Parameters.Add("@iD", OleDbType.Integer)
 cmd.Parameters("@TenButon").Value =  TenButon
cmd.Parameters("@iD").Value =  iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update QUYENCHITIET Set TenButon = @TenButon  where iD= @iD"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@TenButon", SqlDbType.NVarChar)
 cmd.Parameters.Add("@iD", SqlDbType.Int)
 cmd.Parameters("@TenButon").Value =  TenButon
cmd.Parameters("@iD").Value =  iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update QUYENCHITIET Set TenButon =" & TenButon & "  where iD=" & iD & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update QUYENCHITIET Set TenButon =" & TenButon & "  where iD=" & iD & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update QUYENCHITIET Set TenButon =" & TenButon & "  where iD=" & iD & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaTrangthai( ByVal Trangthai as System.Int32, ByVal iD As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update QUYENCHITIET Set Trangthai = ?  where iD= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@Trangthai", OleDbType.Integer)
 cmd.Parameters.Add("@iD", OleDbType.Integer)
 cmd.Parameters("@Trangthai").Value =  Trangthai
cmd.Parameters("@iD").Value =  iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update QUYENCHITIET Set Trangthai = @Trangthai  where iD= @iD"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@Trangthai", SqlDbType.Int)
 cmd.Parameters.Add("@iD", SqlDbType.Int)
 cmd.Parameters("@Trangthai").Value =  Trangthai
cmd.Parameters("@iD").Value =  iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update QUYENCHITIET Set Trangthai =" & Trangthai & "  where iD=" & iD & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update QUYENCHITIET Set Trangthai =" & Trangthai & "  where iD=" & iD & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update QUYENCHITIET Set Trangthai =" & Trangthai & "  where iD=" & iD & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaGhichu( ByVal Ghichu as System.String, ByVal iD As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update QUYENCHITIET Set Ghichu = ?  where iD= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@Ghichu", OleDbType.VarWChar)
 cmd.Parameters.Add("@iD", OleDbType.Integer)
 cmd.Parameters("@Ghichu").Value =  Ghichu
cmd.Parameters("@iD").Value =  iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update QUYENCHITIET Set Ghichu = @Ghichu  where iD= @iD"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@Ghichu", SqlDbType.NVarChar)
 cmd.Parameters.Add("@iD", SqlDbType.Int)
 cmd.Parameters("@Ghichu").Value =  Ghichu
cmd.Parameters("@iD").Value =  iD
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update QUYENCHITIET Set Ghichu =" & Ghichu & "  where iD=" & iD & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update QUYENCHITIET Set Ghichu =" & Ghichu & "  where iD=" & iD & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update QUYENCHITIET Set Ghichu =" & Ghichu & "  where iD=" & iD & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub layBang()
 Chuoi_SQL = " Select * from QUYENCHITIET
 Doc_bang()
 End Sub
 Public Sub layBangTheoiD(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "iD=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from QUYENCHITIET" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoiD(ByVal iD As System.Int32 )
 Chuoi_SQL = " Select * from QUYENCHITIET where  iD = " & iD & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoiD(ByVal iD As System.Int32)
 Dim strsql As String
 strSQL = "Delete From QUYENCHITIET Where iD=" & iD & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoQuyen(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "Quyen=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from QUYENCHITIET" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoQuyen(ByVal Quyen As System.Int32 )
 Chuoi_SQL = " Select * from QUYENCHITIET where  Quyen = " & Quyen & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoQuyen(ByVal Quyen As System.Int32)
 Dim strsql As String
 strSQL = "Delete From QUYENCHITIET Where Quyen=" & Quyen & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTenForm(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "TenForm='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from QUYENCHITIET" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTenForm_like (ByVal TenForm As System.String )
 Chuoi_SQL = " Select * from QUYENCHITIET where  TenForm  like '%" & TenForm & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoTenForm(ByVal TenForm As System.String )
 Chuoi_SQL = " Select * from QUYENCHITIET where  TenForm = '" & TenForm & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTenForm(ByVal TenForm As System.String)
 Dim strsql As String
 strSQL = "Delete From QUYENCHITIET Where TenForm='" & TenForm & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTenButon(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "TenButon='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from QUYENCHITIET" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTenButon_like (ByVal TenButon As System.String )
 Chuoi_SQL = " Select * from QUYENCHITIET where  TenButon  like '%" & TenButon & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoTenButon(ByVal TenButon As System.String )
 Chuoi_SQL = " Select * from QUYENCHITIET where  TenButon = '" & TenButon & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTenButon(ByVal TenButon As System.String)
 Dim strsql As String
 strSQL = "Delete From QUYENCHITIET Where TenButon='" & TenButon & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTrangthai(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "Trangthai=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from QUYENCHITIET" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTrangthai(ByVal Trangthai As System.Int32 )
 Chuoi_SQL = " Select * from QUYENCHITIET where  Trangthai = " & Trangthai & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTrangthai(ByVal Trangthai As System.Int32)
 Dim strsql As String
 strSQL = "Delete From QUYENCHITIET Where Trangthai=" & Trangthai & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoGhichu(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "Ghichu='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from QUYENCHITIET" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoGhichu_like (ByVal Ghichu As System.String )
 Chuoi_SQL = " Select * from QUYENCHITIET where  Ghichu  like '%" & Ghichu & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoGhichu(ByVal Ghichu As System.String )
 Chuoi_SQL = " Select * from QUYENCHITIET where  Ghichu = '" & Ghichu & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoGhichu(ByVal Ghichu As System.String)
 Dim strsql As String
 strSQL = "Delete From QUYENCHITIET Where Ghichu='" & Ghichu & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangNhieuTable
 Chuoi_SQL = " Select iD ,Quyen ,TenForm ,TenButon ,Trangthai ,Ghichu  from QUYENCHITIET"
 Doc_bang()
 End sub
Public Sub TaoTable()
Dim strsql As String
strsql = ""
Select Case ketnoi.MsSql
Case Class_KieuDL.Access 
Case Class_KieuDL.Sql, Class_KieuDL.sqlExpress
strsql = ""
Case Class_KieuDL.SqlCe
strsql = ""
Case Class_KieuDL.Oracle
strsql = ""
Case else 
strsql = ""
End Select
Thuc_hien_lenh(strsql)
    End Sub
#Region "khac"
    Public Sub layBangTheoQuyen(ByVal Quyen As System.Int32, ByVal TENFORM As System.String)
        Chuoi_SQL = " Select  quyen,tenform,tenbuton,trangthai,ghichu from QUYENCHITIET where  quyen=" & Quyen & " and TenForm = '" & TENFORM & "'"
        Doc_bang()
    End Sub
    Public Function KiemTraCo(ByVal Quyen As Integer, ByVal tenForm As String, ByVal Tenbuton As String) As Boolean
        Chuoi_SQL = " Select * from Quyenchitiet where  quyen=" & Quyen & " and TenForm = '" & tenForm & "' and TenButon = '" & Tenbuton & "'   "
        Doc_bang() '
        If Me.Rows.Count > 0 Then Return True
        Return False
    End Function
    Public Sub KiemTraCo(ByVal Quyen As Integer, ByVal tenForm As String)
        Chuoi_SQL = " Select * from Quyenchitiet where  quyen=" & Quyen & " and TenForm = '" & tenForm & "'"
        Doc_bang()
    End Sub
    Public Sub XOA(ByVal quyen As System.Int32, ByVal tenform As Integer, ByVal tenbutton As String)
        Dim strsql As String
        strsql = "Delete From Quyenchitiet Where quyen=" & quyen & " and TenForm='" & tenform & "' and TenButon='" & tenbutton & "'"
        Thuc_hien_lenh(strsql)
    End Sub
#End Region
 End Class

